import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:jinke/entrance/route/routes.dart';
import 'package:jinke/page/report/report_detail/view_make.dart';
import '../controller.dart';
import '../model/ReportEntity.dart';

/// @Author : 王亚东

/// @Time : On 2022/9/13 13:38


 
class ItemReport extends StatelessWidget {
  ReportEntity entity;
  ItemReport(this.entity);


  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: (){
        if(entity.isGenerateGatherReport=='1') {
          Get.toNamed(RouterPath.reportDetailPage, arguments: entity)!.then((value) {
            if(value=='0'){
              Get.find<ReportController>().getListData();
            }
          });
        }else {
          Get.to(MakeReportPage(entity.reportDate??'',entity.specialType??''))!.then((value) {
            if(value==true){
              Get.find<ReportController>().getListData();
            }
          });
        }
      },
      child: Container(
        margin: EdgeInsets.fromLTRB(17.r, 8.r, 17.r, 8.r),
        decoration: BoxDecoration(
            color: Colors.white,
            boxShadow: [
              BoxShadow(
                  offset: const Offset(1, 1),//x,y轴
                  color: const Color(0x1A071428),//投影颜色
                  blurRadius: 4.r//投影距离
              )
            ]

        ),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
              width: 63.r,
              height: 63.r,
              margin: EdgeInsets.all(16.r),
              decoration: BoxDecoration(
                  color: const Color(0xFFF2F3F7),
                  borderRadius: BorderRadius.circular(2.r)
              ),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(entity.tagsDay??'',style: TextStyle(color: const Color(0xff333333),fontSize: 18.r,fontWeight: FontWeight.bold),),
                  SizedBox(height: 5.r,),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Container(color: Colors.black,height: 0.5.r,width: 22.r),
                      Container(
                        decoration: BoxDecoration(
                            color: Colors.black,
                            borderRadius: BorderRadius.circular(180)
                        ),
                        width: 2.r,
                        height: 2.r,
                        margin: EdgeInsets.only(left: 1.r,right: 1.r),
                      ),
                      Container(color: Colors.black,height: 0.5.r,width: 22.r),
                    ],
                  ),
                  SizedBox(height: 6.r,),
                  Text('${DateTime.parse(entity.reportDate??'').year}.${DateTime.parse(entity.reportDate??'').month}',style: TextStyle(color: const Color(0xff333333),fontSize: 12.r,fontWeight: FontWeight.w500),),

                ],
              ),
            ),
            Expanded(child: Container(
              height: 63.r,
              margin: EdgeInsets.only(top: 16.r),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(entity.specialTypeCn??'',style: TextStyle(color: const Color(0xff333333),fontSize: 15.r,fontWeight: FontWeight.bold),),
                  Visibility(visible: entity.isRead=='0'&&entity.isGenerateGatherReport=='1',child: Row(
                    children: [
                      Container(
                        width: 64.r,
                        height: 28.r,
                        margin: EdgeInsets.only(right: 8.r),
                        decoration: BoxDecoration(
                            gradient: const LinearGradient(      //渐变位置
                                begin: Alignment.centerLeft, //右上
                                end: Alignment.centerRight, //左下
                                stops: [0.0, 1.0],         //[渐变起始点, 渐变结束点]
                                //渐变颜色[始点颜色, 结束颜色]
                                colors: [Color(0xff00A9FE), Color(0xFF0173FE)]
                            ),
                            borderRadius: BorderRadius.circular(2.r)
                        ),
                        child: Center(child: Text('前往查阅',style: TextStyle(color: Colors.white,fontSize: 12.r,fontWeight: FontWeight.w500),),),
                      ),
                      Text('今日报告已生成',style: TextStyle(color: Color(0xFF0086F6),fontSize: 13.r,fontWeight: FontWeight.w500),)
                    ],
                  ),),
                  Visibility(visible: entity.isRead!='1'&&entity.isGenerateGatherReport=='0',child: Container(
                    width: 64.r,
                    height: 28.r,
                    margin: EdgeInsets.only(right: 8.r),
                    decoration: BoxDecoration(
                        gradient: const LinearGradient(      //渐变位置
                            begin: Alignment.centerLeft, //右上
                            end: Alignment.centerRight, //左下
                            stops: [0.0, 1.0],         //[渐变起始点, 渐变结束点]
                            //渐变颜色[始点颜色, 结束颜色]
                            colors: [Colors.orangeAccent, Color(0xFFEF7F13)]
                        ),
                        borderRadius: BorderRadius.circular(2.r)
                    ),
                    child: Center(child: Text('一键生成',style: TextStyle(color: Colors.white,fontSize: 12.r,fontWeight: FontWeight.w500),),),
                  ),),
                  Visibility(visible: entity.isRead=='1'&&entity.isGenerateGatherReport=='1',child: Text('共${entity.reportEvolve??'0'}条项目进展',style: TextStyle(color: Color(0xff999999),fontSize: 12.r,fontWeight: FontWeight.w500),))
                ],
              ),
            )),
            Visibility(
                visible: entity.isGenerateGatherReport!='1'||entity.isRead!='1',
                child: Container(
                  width: 52.r,
                  height: 23.r,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.only(bottomLeft: Radius.circular(4.r),topRight: Radius.circular(4.r)),
                    color: const Color(0xFFEF7F13),
                  ),
                  child: Center(child: Text(entity.isGenerateGatherReport!='1'?'未生成':'未查阅',style: TextStyle(color: Colors.white,fontSize: 12.r),),),
                ))
          ],
        ),
      ),
    );
  }
}
